﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RentAWorker.Business.Interfaces;
using RentAWorker.Business.DTO;
using RentAWorker.Desktop.Entities;

namespace Services
{
    public class DummyResourceManagementService : IManageResourceService
    {
        public RentResource GetResource(int id)
        {
            return new Worker()
            {
                Location = new Location()
                {
                    LocationName = "Innsbruck"
                },
                Name = "Worker " + id,
                SSNo = "1234"
            };
        }

        public RentResource[] GetResourcesByLocation(string location, ResourceType? resType)
        {
            if (String.IsNullOrEmpty(location))
            {
                location = "Innsbruck";
            }

            Location loc = new Location()
            {
                LocationName = location
            };

            var result = new List<RentResource>()
            {
                new Worker()
                {
                    Location = loc, Name = "Max Knor", SSNo="1234"
                },
                new Worker()
                {
                    Location = loc, Name = "Mario Szpuszta", SSNo="1235"
                },
                new Worker()
                {
                    Location = loc, Name = "Andreas Pollak", SSNo="1236"
                },
                new Machine()
                {
                    Location = loc, 
                    MachineType = new MachineType()
                    {
                        MachineTypeName = "Hammer"
                    },
                    Name = "Mein toller Hammer",
                    SerialNo = "12345",
                    Status = "In Ordnung"
                },
                new Machine()
                {
                    Location = loc, 
                    MachineType = new MachineType()
                    {
                        MachineTypeName = "Bagger"
                    },
                    Name = "Mein toller Bagger",
                    SerialNo = "12346",
                    Status = "In Ordnung"
                }
            };
            if (resType != null)
            {
                switch (resType.Value)
                {
                    case ResourceType.Machine:
                        return result.Where(p => p is Machine).ToArray();
                        break;
                    case ResourceType.Worker:
                        return result.Where(p => p is Worker).ToArray();
                        break;
                    default:
                        break;
                }
            }
            return result.ToArray();
        }

        public RentResource SubmitResource(RentResource resourceToCreate)
        {
            return resourceToCreate;
        }

        public void UpdateResource(RentResource resourceToUpdate)
        {
        }

        public void DeleteResource(int id)
        {
        }
    }
}
